package cn.tedu.ivos.dict.controller;


import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.dict.pojo.dto.DictParam;
import cn.tedu.ivos.dict.pojo.dto.DictQuery;
import cn.tedu.ivos.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/v1/dict")
public class DictController {
    @Autowired
    private DictService dictService;

    @GetMapping("select")
    public JsonResult select(DictQuery dictQuery) {
        log.info("查询字典：DictQuery={}", dictQuery);
        return JsonResult.ok(dictService.select(dictQuery));
    }

    @PostMapping("save")
    public JsonResult save(DictParam dictParam) {
        log.info("保存字典：DictQuery={}", dictParam);
        dictService.save(dictParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id) {
        log.info("删除字典：id={}", id);
        dictService.delete(id);
        return JsonResult.ok();
    }
}
